package com.molichuxing.services.infrastructure.convertor;

import com.molichuxing.services.business.dto.response.MessageResDto;
import com.molichuxing.services.business.dto.response.VehicleBizDto;
import com.molichuxing.services.business.dto.response.VehicleInfoBizDto;
import com.molichuxing.services.business.dto.response.VehicleNameBizDto;
import com.molichuxing.services.infrastructure.bean.*;
import com.molichuxing.services.infrastructure.dto.request.create.StatisticsOrderCreateDto;
import com.molichuxing.services.infrastructure.dto.response.*;
import com.molichuxing.services.property.VehicleEngineTypeEnum;
import com.molichuxing.services.property.VehicleModleBodyFormEnum;
import com.molichuxing.services.property.VehicleModleLevelEnum;
import com.molichuxing.services.property.VehiclePowerTypeEnum;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

public class Convert {


    public static List<PurchaseParamDicDto> toDeliveryParamDicDto(List<PurchaseParamDicBean> beanList) {
        List<PurchaseParamDicDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (PurchaseParamDicBean bean : beanList) {
                dtoList.add(toDeliveryParamDicDto(bean));
            }
        }

        return dtoList;
    }

    public static PurchaseParamDicDto toDeliveryParamDicDto(PurchaseParamDicBean bean) {
        PurchaseParamDicDto beanDto = null;
        if (bean != null) {
            beanDto = new PurchaseParamDicDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }


    public static List<MessageResDto> toMessageResDto(List<MessageCenter> beanList) {
        List<MessageResDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (MessageCenter bean : beanList) {
                dtoList.add(toMessageResDto(bean));
            }
        }

        return dtoList;
    }

    public static MessageResDto toMessageResDto(MessageCenter bean) {
        MessageResDto beanDto = null;
        if (bean != null) {
            beanDto = new MessageResDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }


    public static MessageTemplateDto toMessageTemplateDto(MessageTemplateBean bean) {
        MessageTemplateDto beanDto = null;
        if (bean != null) {
            beanDto = new MessageTemplateDto();
            BeanUtils.copyProperties(bean, beanDto);
        }
        return beanDto;
    }
    
    public static List<MessageTemplateDto> toMessageTemplateDto(List<MessageTemplateBean> beanList) {
        List<MessageTemplateDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (MessageTemplateBean bean : beanList) {
                dtoList.add(toMessageTemplateDto(bean));
            }
        }
        return dtoList;
    }

    public static List<SubcompanyDto> toSubcompanyDto(List<SubcompanyBean> beanList) {
        List<SubcompanyDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (SubcompanyBean bean : beanList) {
                dtoList.add(toSubcompanyDto(bean));
            }
        }

        return dtoList;
    }

    public static SubcompanyDto toSubcompanyDto(SubcompanyBean bean) {
        SubcompanyDto beanDto = null;
        if (bean != null) {
            beanDto = new SubcompanyDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static List<RegionDto> toRegionBeanDto(List<RegionBean> beanList) {
        List<RegionDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (RegionBean bean : beanList) {
                dtoList.add(toRegionBeanDto(bean));
            }
        }

        return dtoList;
    }

    public static RegionDto toRegionBeanDto(RegionBean bean) {
        RegionDto beanDto = null;
        if (bean != null) {
            beanDto = new RegionDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }


    // 车型转换
    public static List<VehicleDto> toVehicleBeanDto(List<VehicleBean> beanList) {
        List<VehicleDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (VehicleBean bean : beanList) {
                dtoList.add(toVehicleBeanDto(bean));
            }
        }
        return dtoList;
    }

    public static VehicleDto toVehicleBeanDto(VehicleBean bean) {
        VehicleDto beanDto = null;
        if (bean != null) {
            beanDto = new VehicleDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setPowerTypeStr(VehiclePowerTypeEnum.getName(bean.getPowerType()));
            Integer engineType = bean.getEngineType();
            if(engineType != null){
                beanDto.setEngineTypeStr(VehicleEngineTypeEnum.getName(engineType));
            }
        }

        return beanDto;
    }

    // 车型图片
    public static VehiclePictureDto toVehiclePictureBeanDto(VehiclePictureBean bean) {
        VehiclePictureDto beanDto = null;
        if (bean != null) {
            beanDto = new VehiclePictureDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    // 车型图片
    public static List<VehiclePictureDto> toVehiclePictureBeanDto(List<VehiclePictureBean> beanList) {
        List<VehiclePictureDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (VehiclePictureBean bean : beanList) {
                dtoList.add(toVehiclePictureBeanDto(bean));
            }
        }

        return dtoList;
    }

    //保险公司转换
    public static List<InsuranceCompanyDto> toInsuranceCompanyBeanDto(List<InsuranceCompanyBean> beanList) {
        List<InsuranceCompanyDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (InsuranceCompanyBean bean : beanList) {
                dtoList.add(toInsuranceCompanyBeanDto(bean));
            }
        }
        return dtoList;
    }

    public static InsuranceCompanyDto toInsuranceCompanyBeanDto(InsuranceCompanyBean bean) {
        InsuranceCompanyDto beanDto = null;
        if (bean != null) {
            beanDto = new InsuranceCompanyDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    // 分子公司转换
    public static SubcompanyDto toSubcompanyBeanDto(SubcompanyBean bean) {
        SubcompanyDto beanDto = null;
        if (bean != null) {
            beanDto = new SubcompanyDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static List<SubcompanyDto> toSubcompanyDtoList(List<SubcompanyBean> beanList) {
        List<SubcompanyDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (SubcompanyBean bean : beanList) {
                dtoList.add(toSubcompanyBeanDto(bean));
            }
        }
        return dtoList;
    }

    // 颜色
    public static VehicleColorDto toVehicleColorBeanDto(VehicleColorBean bean) {
        VehicleColorDto beanDto = null;
        if (bean != null) {
            beanDto = new VehicleColorDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static List<VehicleColorDto> toVehicleColorBeanDto(List<VehicleColorBean> beanList) {
        List<VehicleColorDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (VehicleColorBean bean : beanList) {
                dtoList.add(toVehicleColorBeanDto(bean));
            }
        }
        return dtoList;
    }

    // 车系
    public static List<VehicleModleDto> toVehicleModleDto(List<VehicleModleBean> beanList) {
        List<VehicleModleDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (VehicleModleBean bean : beanList) {
                dtoList.add(toVehicleModleDto(bean));
            }
        }
        return dtoList;
    }

    public static VehicleModleDto toVehicleModleDto(VehicleModleBean bean) {
        VehicleModleDto beanDto = null;
        if (bean != null) {
            beanDto = new VehicleModleDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setBodyFormStr(VehicleModleBodyFormEnum.getName(bean.getBodyForm()));
            beanDto.setModelLevelStr(VehicleModleLevelEnum.getName(bean.getModelLevel()));
        }

        return beanDto;
    }

    // 子品牌
    public static List<VehicleMakeDto> toVehicleMakeDto(List<VehicleMakeBean> beanList) {
        List<VehicleMakeDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (VehicleMakeBean bean : beanList) {
                dtoList.add(toVehicleMakeDto(bean));
            }
        }
        return dtoList;
    }

    public static VehicleMakeDto toVehicleMakeDto(VehicleMakeBean bean) {
        VehicleMakeDto beanDto = null;
        if (bean != null) {
            beanDto = new VehicleMakeDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    // 分子公司列表数据转换
    public static List<SubcompanyDto> toSubcompanyPageBeanDto(List<SubcompanyBean> beanList) {
        List<SubcompanyDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (SubcompanyBean bean : beanList) {
                dtoList.add(toSubcompanyBeanDto(bean));
            }
        }
        return dtoList;
    }

    // 产权公司
    public static OwnershipDto toOwnershipBeanDto(OwnershipBean bean) {
        OwnershipDto beanDto = null;
        if (bean != null) {
            beanDto = new OwnershipDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    // 产权人列表转换
    public static List<OwnershipDto> toOwnershipPageBeanDto(List<OwnershipBean> beanList) {
        List<OwnershipDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (OwnershipBean bean : beanList) {
                dtoList.add(toOwnershipBeanDto(bean));
            }
        }
        return dtoList;
    }

    // 消息推送转换
    public static MsgPushDto toMsgPushBeanDto(MsgPushBean bean) {
        MsgPushDto beanDto = null;
        if (bean != null) {
            beanDto = new MsgPushDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    // 消息推送列表数据转换
    public static List<MsgPushDto> toMsgPushPageBeanDto(List<MsgPushBean> beanList) {
        List<MsgPushDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (MsgPushBean bean : beanList) {
                dtoList.add(toMsgPushBeanDto(bean));
            }
        }
        return dtoList;
    }

    public static List<FileStorageConfigDto> toFileStorageConfigDto(List<FileStorageConfigBean> beanList) {
        List<FileStorageConfigDto> dtoList = null;
        if (beanList != null && !beanList.isEmpty()) {
            dtoList = new ArrayList<>();
            for (FileStorageConfigBean bean : beanList) {
                dtoList.add(toFileStorageConfigDto(bean));
            }
        }
        return dtoList;
    }

    public static FileStorageConfigDto toFileStorageConfigDto(FileStorageConfigBean bean) {
        FileStorageConfigDto beanDto = null;
        if (bean != null) {
            beanDto = new FileStorageConfigDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static List<ReceiptCompanyDto> toReceiptCompanyDto(List<ReceiptCompanyBean> beanList) {
        List<ReceiptCompanyDto> dtoList = null;
        if (beanList != null && !beanList.isEmpty()) {
            dtoList = new ArrayList<>();
            for (ReceiptCompanyBean bean : beanList) {
                dtoList.add(toReceiptCompanyDto(bean));
            }
        }
        return dtoList;
    }

    public static ReceiptCompanyDto toReceiptCompanyDto(ReceiptCompanyBean bean) {
        ReceiptCompanyDto beanDto = null;
        if (bean != null) {
            beanDto = new ReceiptCompanyDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static List<ReceiptCompanyBankDto> toReceiptCompanyBankDto(List<ReceiptCompanyBankBean> beanList) {
        List<ReceiptCompanyBankDto> dtoList = null;
        if (beanList != null && !beanList.isEmpty()) {
            dtoList = new ArrayList<>();
            for (ReceiptCompanyBankBean bean : beanList) {
                dtoList.add(toReceiptCompanyBankDto(bean));
            }
        }
        return dtoList;
    }

    public static ReceiptCompanyBankDto toReceiptCompanyBankDto(ReceiptCompanyBankBean bean) {
        ReceiptCompanyBankDto beanDto = null;
        if (bean != null) {
            beanDto = new ReceiptCompanyBankDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static List<RegionInfoDto> toProvinceDto(List<RegionBean> beanList) {
        List<RegionInfoDto> dtoList = null;
        if (beanList != null && !beanList.isEmpty()) {
            dtoList = new ArrayList<>();
            for (RegionBean bean : beanList) {
                dtoList.add(toProvinceDto(bean));
            }
        }
        return dtoList;
    }

    public static RegionInfoDto toProvinceDto(RegionBean bean) {
        RegionInfoDto beanDto = null;
        if (bean != null) {
            beanDto = new RegionInfoDto();
            beanDto.setProvinceId(bean.getId());
            beanDto.setProvinceFullName(bean.getFullName());
            beanDto.setProvinceName(bean.getName());
        }

        return beanDto;
    }


    /*****************************车型 配置信息开始**********************************************/
    public static List<VehicleModelParamDto> toVehicleModelParamDto(List<VehicleModelParamBean> beanList) {
        List<VehicleModelParamDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (VehicleModelParamBean bean : beanList) {
                dtoList.add(toVehicleModelParamDto(bean));
            }
        }

        return dtoList;
    }

    public static VehicleModelParamDto toVehicleModelParamDto(VehicleModelParamBean bean) {
        VehicleModelParamDto beanDto = null;
        if (bean != null) {
            beanDto = new VehicleModelParamDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static VersionInfoDto toVersionInfoDto(VersionInfoBean bean) {
        VersionInfoDto beanDto = null;
        if (bean != null) {
            beanDto = new VersionInfoDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }

    public static VersionMobileDto toVersionMobileDto(VersionMobileBean bean) {
        VersionMobileDto beanDto = null;
        if (bean != null) {
            beanDto = new VersionMobileDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }


    public static List<VersionContentDto> toVersionContentDto(List<VersionContentBean> beanList) {
        List<VersionContentDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (VersionContentBean bean : beanList) {
                dtoList.add(toVersionContentDto(bean));
            }
        }

        return dtoList;
    }

    public static VersionContentDto toVersionContentDto(VersionContentBean bean) {
        VersionContentDto beanDto = null;
        if (bean != null) {
            beanDto = new VersionContentDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }


    public static List<VehicleBizDto> toVehicleBizDto(List<VehicleDto> beanList) {
        List<VehicleBizDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (VehicleDto bean : beanList) {
                dtoList.add(toVehicleBizDto(bean));
            }
        }

        return dtoList;
    }

    public static VehicleBizDto toVehicleBizDto(VehicleDto bean) {
        VehicleBizDto beanDto = null;
        if (bean != null) {
            beanDto = new VehicleBizDto();
            BeanUtils.copyProperties(bean, beanDto);
        }

        return beanDto;
    }


    /*****************************车型 配置信息结束**********************************************/

    public static List<AdvertisingInfoDto> toAdvertisingInfoDto(List<AdvertisingInfoBean> beanList) {
        List<AdvertisingInfoDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (AdvertisingInfoBean bean : beanList) {
                dtoList.add(toAdvertisingInfoDto(bean));
            }
        }

        return dtoList;
    }

    private static AdvertisingInfoDto toAdvertisingInfoDto(AdvertisingInfoBean bean) {
        AdvertisingInfoDto dto = null;
        if (bean != null) {
            dto = new AdvertisingInfoDto();
            BeanUtils.copyProperties(bean, dto);
        }

        return dto;
    }

    public static List<DeliveryParamDicDto> toDeliveryParamDicDtoList(List<DeliveryParamDicBean> beanList) {
        List<DeliveryParamDicDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (DeliveryParamDicBean bean : beanList) {
                dtoList.add(toDeliveryParamDicDto(bean));
            }
        }

        return dtoList;
    }

    public static DeliveryParamDicDto toDeliveryParamDicDto(DeliveryParamDicBean bean) {
        DeliveryParamDicDto dto = null;
        if (bean != null) {
            dto = new DeliveryParamDicDto();
            BeanUtils.copyProperties(bean, dto);
        }
        return dto;
    }
    
    public static List<RiskEmailDto> toRiskEmailDtoList(List<RiskEmailBean> beanList) {
        List<RiskEmailDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (RiskEmailBean bean : beanList) {
                dtoList.add(toRiskEmailDto(bean));
            }
        }

        return dtoList;
    }

    public static RiskEmailDto toRiskEmailDto(RiskEmailBean bean) {
    	RiskEmailDto dto = null;
        if (bean != null) {
            dto = new RiskEmailDto();
            BeanUtils.copyProperties(bean, dto);
        }
        return dto;
    }

    public static StatisticsOrderBean toStatisticsOrderBean(StatisticsOrderCreateDto dto) {
        StatisticsOrderBean bean = null;
        if (dto != null) {
            bean = new StatisticsOrderBean();
            BeanUtils.copyProperties(dto, bean);
        }
        return bean;
    }



    public static StatisticsOrderDto toStatisticsOrderDto(StatisticsOrderBean bean) {
        StatisticsOrderDto dto = null;
        if (bean != null) {
            dto = new StatisticsOrderDto();
            BeanUtils.copyProperties(bean, dto);
        }
        return dto;
    }

    public static List<VehicleInfoBizDto> toVehicleInfoBizDtoList(List<VehicleDto> beanList) {
        List<VehicleInfoBizDto> dtoList = null;
        if (beanList != null && beanList.size() > 0) {
            dtoList = new ArrayList<>();
            for (VehicleDto dto : beanList) {
                dtoList.add(toVehicleInfoBizDto(dto));
            }
        }

        return dtoList;
    }

    public static VehicleInfoBizDto toVehicleInfoBizDto(VehicleDto dto) {
        VehicleInfoBizDto bizDto = null;
        if (dto != null) {
            bizDto = new VehicleInfoBizDto();
            BeanUtils.copyProperties(dto, bizDto);
            bizDto.setModelId(dto.getId());
            bizDto.setModelName(dto.getName());
        }
        return bizDto;
    }

    public static VehicleInfoBizDto toVehicleInfoBizDto(VehicleModleDto dto,VehicleInfoBizDto bizDto) {
        if (dto != null) {
            LocalDateTime gmtCreate = bizDto.getGmtCreate();
            BeanUtils.copyProperties(dto, bizDto);
            bizDto.setSeriesId(dto.getId());
            bizDto.setSeriesName(dto.getName());
            bizDto.setGmtCreate(gmtCreate);
        }
        return bizDto;
    }

    public static VehicleInfoBizDto toVehicleInfoBizDto(VehicleMakeDto dto,VehicleInfoBizDto bizDto) {
        if (dto != null) {
            LocalDateTime gmtCreate = bizDto.getGmtCreate();
            BeanUtils.copyProperties(dto, bizDto);
            bizDto.setSubBrandId(dto.getId());
            bizDto.setSubBrandName(dto.getName());
            bizDto.setGmtCreate(gmtCreate);
        }
        return bizDto;
    }

    public static VehicleInfoBizDto toVehicleInfoBizMainDto(VehicleMakeDto dto,VehicleInfoBizDto bizDto) {
        if (dto != null) {
            LocalDateTime gmtCreate = bizDto.getGmtCreate();
            BeanUtils.copyProperties(dto, bizDto);
            bizDto.setBrandName(dto.getName());
            bizDto.setGmtCreate(gmtCreate);
        }
        return bizDto;
    }

	public static List<AdvertDto> toAdvertDto(List<AdvertBean> beanList) {
		 List<AdvertDto> dtoList = null;
	        if (beanList != null && beanList.size() > 0) {
	            dtoList = new ArrayList<>();
	            for (AdvertBean bean : beanList) {
	                dtoList.add(toAdvertDto(bean));
	            }
	        }
	        return dtoList;
	}

    public static AdvertDto toAdvertDto(AdvertBean bean) {
    	AdvertDto beanDto = null;
        if (bean != null) {
            beanDto = new AdvertDto();
            BeanUtils.copyProperties(bean, beanDto);
            beanDto.setAddTime(bean.getGmtCreate());
        }
        return beanDto;
    }

}
